package com.whmall.service.crm.module.companycertificatechemical.enumeration;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * 审批状态
 *
 * @author alex
 * @since 2020/12/18
 */
public enum ApproveStatusEnum {
    /**
     * 已取消
     */
    CANCELLED(-2),

    /**
     * 审核驳回
     */
    REJECTED(-1),

    /**
     * 审核中
     */
    REVIEW(0),

    /**
     * 审核通过
     */
    PASSED(1);

    @JsonCreator
    public static ApproveStatusEnum fromNullableValue(Integer value) {
        if (null == value) {
            return null;
        }

        return fromValue(value);
    }

    public static ApproveStatusEnum fromValue(int value) {
        for (ApproveStatusEnum anEnum : values()) {
            if (anEnum.getValue() == value) {
                return anEnum;
            }
        }

        throw new UnsupportedOperationException("不支持的审批状态=" + value);
    }

    ApproveStatusEnum(int value) {
        this.value = value;
    }

    private final int value;

    @JsonValue
    public int getValue() {
        return value;
    }
}
